package bussines.logger;

import java.util.ArrayList;
import java.util.List;

public class Log {

	private enum LogLevel {
		LOG, DEBUG
	};

	private final static LogLevel DEFAULT_LOG = LogLevel.LOG;
	private static List<LogListener> listeners = new ArrayList<LogListener>();

	public static void debug(String text) {
		if (DEFAULT_LOG.equals(LogLevel.DEBUG)) {
			log(text);
		}
	}

	public static void log(String text) {
		if (DEFAULT_LOG.equals(LogLevel.LOG)) {
			doLog(text);
			for (LogListener listener : listeners) {
				listener.onLog(text);
			}
		}
	}

	private static void doLog(String text) {
		System.out.println(text);
	}

	public static void addListener(LogListener ll) {
		listeners.add(ll);

	}
}
